package com.example.kuaizu.controller;

import com.example.kuaizu.pojo.ReviewParam;
import com.example.kuaizu.pojo.UpdateUserInfoParam;
import com.example.kuaizu.pojo.pram.TalentAuditParam;
import com.example.kuaizu.service.InHoutaiService;
import com.example.kuaizu.service.InUserService;
import com.example.kuaizu.utils.AjaxResponse;
import jakarta.validation.Valid;
import kuaizu.common.groups.Delect;
import kuaizu.common.groups.Update;
import kuaizu.common.param.NoAuditProjectParam;
import kuaizu.common.param.QueryTalentParam;
import kuaizu.common.param.StudentInfoListParam;
import kuaizu.common.param.UpdateAuditStatusParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/hou")
@RequiredArgsConstructor
public class HouTaiController {

    private final InUserService inUserService;
    private final InHoutaiService inHoutaiService;
    //审核学生证认证信息   被审核openid 审核人的id 姓名 审核状态 审核信息
    @PostMapping("/reviewstudent")
    public AjaxResponse reviewstudent(@RequestBody @Valid ReviewParam reviewParam) {
        inUserService.reviewstudent(reviewParam);
        return AjaxResponse.success("审核成功");
    }

    //查询指定学校的审核信息
    @GetMapping("/querystudent/{id}")
    public AjaxResponse querystudent(@PathVariable Integer id) {
        return inUserService.queryStudent(id);
    }

    
    //查询学校学生的注册信息
    @PostMapping("/querystudentinfo/all")
    public AjaxResponse querystudentinfo(
            @RequestBody
            @Valid
            StudentInfoListParam queryStudentInfoParam) {

        return AjaxResponse.success("查询成功",inHoutaiService.queryStudentInfo(queryStudentInfoParam));
    }

    //修改用户信息
    @PostMapping("/updateUserInfo")
    public AjaxResponse updateUserInfo(@RequestBody @Validated(Update.class) UpdateUserInfoParam updateUserInfoParam) {
        inHoutaiService.updateUserInfo(updateUserInfoParam);
        return AjaxResponse.success("修改成功");
    }

    //注销用户
    @PostMapping("/userOffline")
    public AjaxResponse userOffline(@RequestBody @Validated(Delect.class) UpdateUserInfoParam userOfflineParam) {
        inUserService.userOffline(userOfflineParam);
        return AjaxResponse.success("注销成功");
    }
    //获取注册学生的学校专业人数信息
    @PostMapping("/getSchoolStudentInfo")
    public AjaxResponse getSchoolStudentInfo() {
        return AjaxResponse.success("获取成功",inHoutaiService.getSchoolStudentInfo());
    }

    //审核项目
    @PostMapping("/project/audit")
    public AjaxResponse auditProject(@RequestBody @Validated UpdateAuditStatusParam param) {
        inHoutaiService.updateAuditStatus(param);
        return AjaxResponse.success("审核成功");
    }
    //获取未审核的项目信息
    @PostMapping("/project/getNoAuditProject")
    public AjaxResponse getNoAuditProject(@RequestBody @Validated NoAuditProjectParam param) {
        return AjaxResponse.success("获取成功", inHoutaiService.getNoAuditProject(param));
    }

    //人才审核
    @PostMapping("/talent/audit")
    public AjaxResponse talentAudit(@RequestBody @Validated TalentAuditParam param) {
        return AjaxResponse.success("审核成功", inHoutaiService.talentAudit(param));
    }

    //分页查询人才信息
    @PostMapping("/talent/query")
    public AjaxResponse queryTalentParam(@RequestBody @Validated QueryTalentParam param) {
        return AjaxResponse.success("查询成功", inHoutaiService.queryTalentInfo(param));
    }
}
